<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/jsp/common/tagPage.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <title>中底数据列表</title>
    <meta name="keywords" content="中文"/>
    <meta name="description" content="下载"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>

    <!-- basic styles -->
    <link href="${baseurl}statics/assets/css/bootstrap.min.css" rel="stylesheet"/>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/font-awesome.min.css"/>

    <!--[if IE 7]>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/font-awesome-ie7.min.css"/>
    <![endif]-->
    <!-- fonts -->

    <link rel="stylesheet" href="${baseurl}statics/assets/css/fonts.css"/>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/translateelement.css"/>

    <!-- ace styles -->

    <link rel="stylesheet" href="${baseurl}statics/assets/css/ace.min.css"/>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/ace-rtl.min.css"/>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/ace-skins.min.css"/>

    <!--[if lte IE 8]>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/ace-ie.min.css"/>
    <![endif]-->

    <!-- inline styles related to this page -->
    <!-- 公共的js -->
    <script src="${baseurl}statics/assets/js/common.js"></script>
    <!-- ace settings handler -->

    <script src="${baseurl}statics/assets/js/ace-extra.min.js"></script>

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->

    <script type="text/javascript" src="${baseurl}statics/assets/js/jquery-1.10.2.min.js"></script>

    <!--[if lt IE 9]>
    <script src="${baseurl}statics/assets/js/html5shiv.js"></script>
    <script src="${baseurl}statics/assets/js/respond.min.js"></script>
    <![endif]-->

    <script type="text/javascript">
        $(function() {
            $.ajax({
                url: "${baseurl}insole/selectInsoleKey",
                type: "post",
                dataType:"json",
                success: function (json) {
                    if(json.insoleKey==1){
                        $("#checkAll").hide();
                        $("#noCheckAll").show();
                    }else{
                        $("#noCheckAll").hide();
                        $("#checkAll").show();
                    }
                },
                error: function (json) {
                    alert("error");
                }
            });
        });
    </script>
</head>

<body>

<div class="breadcrumbs" id="breadcrumbs">
    <script type="text/javascript">
        try {
            ace.settings.check('breadcrumbs', 'fixed')
        } catch (e) {
        }
    </script>

    <ul class="breadcrumb">
        <li>
            <i class="icon-home home-icon"></i>
            <a href="#">中底管理</a>
        </li>

        <li>
            <a href="${baseurl}insole/selectList">中底列表</a>
        </li>
        <li class="active">中底数据列表</li>
    </ul><!-- .breadcrumb -->
</div>

<div class="page-content">
    <div class="row">
        <div class="col-xs-12">
            <div class="row">
                <div class="col-xs-12">
                    <h3 class="header smaller lighter blue">中底数据列表</h3>
                    <div class="table-header">
                        中底数据列表信息
                    </div>
                    <div class="table-responsive">


                        <div style="width: 25%"  class="system_top_l clearfix">
                            <form class="form-search" action="${baseurl}insole/selectList"
                                  method="post">
                                <div class="row" style="margin-top: 20px;float: left;">
                                    <div class="col-xs-12 col-sm-8">
                                        <div class="input-group">
                                            <input type="text" class="form-control search-query" name="keywords"
                                                   placeholder="请输入关键词"/>
                                            <span class="input-group-btn">
                                                <button type="submit" class="btn btn-purple btn-sm">
                                                    搜索
                                                    <i class="icon-search icon-on-right bigger-110"></i>
                                                </button>
                                            </span>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <!-- 时间筛选 -->
                        <div style="float: left;"  class="system_top_r clearfix">
                            <shiro:hasPermission name="insole:add">
                                <div style="margin-top: 20px;">
                                    <div id="inPermission">
                                        <a class="btn btn-purple btn-sm" href="${baseurl}insole/addInsole"
                                        >添加</a>

                                    </div>
                                </div>


                            </shiro:hasPermission>
                            <shiro:hasPermission name="insole:checked">
                                <div style="float: left;margin-top: 20px;">
                                    <!--一键审核按钮-->
                                    <div  class="open1">
                                        <input type="button" id="checkAll" value="一键审核" style="background-color: #9585bf !important;color: #fff;height: 36px;border: none;"/>
                                    </div>
                                    <!--取消一键审核按钮-->
                                    <div class="open1">
                                        <input type="button" id="noCheckAll" value="取消一键审核" style="background-color: #9585bf !important;color: #fff;height: 36px;border: none;">
                                    </div>
                                </div>
                            </shiro:hasPermission>
                        </div>
                        <input type="hidden" id="adminName" value="${sysUserManage.userName}">
                        <table id="sample-table-2" class="table table-striped table-bordered table-hover"
                               style="margin-top: 20px;">
                            <thead>
                            <tr>
                                <th class="center">
                                    <label>
                                        <input type="checkbox" class="ace"/>
                                        <span class="lbl"></span>
                                    </label>
                                </th>
                                <th style="text-align: center">Id</th>
                                <th style="text-align: center">中底型号</th>
                                <th style="text-align: center">鞋类型</th>
                                <th style="text-align: center">中底工艺</th>
                                <th style="text-align: center">季节款式</th>
                                <th style="text-align: center">功能分类</th>
                                <th style="text-align: center">鞋头形状</th>
                                <th style="text-align: center">前掌/整只材质</th>
                                <th style="text-align: center">中底板</th>
                                <th style="text-align: center">跟高</th>
                                <th style="text-align: center">毛重</th>
                                <th style="text-align: center">日产能</th>
                                <th style="text-align: center">审核状态</th>
                                <th style="text-align: center">业务状态</th>
                                <th style="text-align: center">
                                    业务操作
                                </th>
                            </tr>
                            </thead>

                            <tbody>
                            <c:forEach items="${page.records}" var="insole">
                                <tr>
                                    <td class="center">
                                        <label>
                                            <input type="checkbox" class="ace"/>
                                            <span class="lbl"></span>
                                        </label>
                                    </td>
                                    <td style="text-align: center">${insole.id}</td>
                                    <td style="text-align: center">
                                        ${insole.model}
                                    </td>
                                    <td style="text-align: center">
                                        <c:if test="${insole.shoesType eq 'W'}">女鞋</c:if>
                                        <c:if test="${insole.shoesType eq 'M'}">男鞋</c:if>
                                        <c:if test="${insole.shoesType eq 'K'}">童鞋</c:if>
                                    </td>
                                    <td style="text-align: center">
                                        <c:if test="${insole.midsole eq 'T'}">传统</c:if>
                                        <c:if test="${insole.midsole eq 'P'}">注塑</c:if>
                                        <c:if test="${insole.midsole eq 'R'}">PU一体</c:if>
                                    </td>
                                    <td style="text-align: center">${insole.seasonStyle}</td>
                                    <td style="text-align: center">${insole.classify}</td>
                                    <td style="text-align: center">${insole.shape}</td>
                                    <td style="text-align: center">${insole.texture}</td>
                                    <td style="text-align: center">${insole.midsoleBoard}</td>
                                    <td style="text-align: center">${insole.heelHeight}</td>
                                    <td style="text-align: center">${insole.grossWeight}</td>
                                    <td style="text-align: center">${insole.dailyCapacity}</td>
                                    <td style="text-align: center">
                                            <c:if test="${count==0}">
                                                <c:if test="${insole.status == 1}">审核中</c:if>
                                                <c:if test="${insole.status == 2}"><span
                                                        style="color: green;font-weight: bold">审核通过</span></c:if>
                                                <c:if test="${insole.status == 3}"><span
                                                        style="color: red;font-weight: bold">审核不通过</span>(请修改)</c:if>
                                            </c:if>
                                            <c:if test="${count==1}">
                                                <c:if test="${insole.status == 2}"> <span
                                                        style="color: green;font-weight: bold">审核通过</span> </c:if>
                                                <c:if test="${insole.status == 1}">审核中
                                                    <a href="javascript:onclick = changeCheckStatus('${insole.id}',2);">通过</a>
                                                    <a href="javascript:onclick = changeCheckStatus('${insole.id}',3);">不通过</a>
                                                </c:if>
                                                <c:if test="${insole.status == 3}"><span
                                                        style="color: red;font-weight: bold">审核不通过</span>
                                                </c:if>
                                           </c:if>
                                    </td>
                                    <td style="text-align: center">
                                        <c:if test="${insole.valid == 0}">
                                            禁用
                                        </c:if>
                                        <c:if test="${insole.valid == 1}">
                                            启用
                                        </c:if>
                                        <c:if test="${insole.valid == 2}">
                                            启用
                                        </c:if>
                                    </td>
                                    <td style="text-align: center">
                                        <div class="visible-md visible-lg hidden-sm hidden-xs action-buttons">
                                            <shiro:hasPermission name="insole:find">
                                                <a class="blue" href="${baseurl}insole/detail?id=${insole.id}"
                                                   target="iframe_bt">
                                                    详情
                                                </a>
                                            </shiro:hasPermission>
                                            <!--审核不通过的情况下要进行修改-->
                                            <shiro:hasPermission name="insole:update">
                                                <c:if test="${insole.status == 3 && insole.valid != 0}">
                                                    <a class="green" href="${baseurl}insole/updateDetail?insoleId=${insole.id}">
                                                        修改
                                                    </a>
                                                </c:if>
                                            </shiro:hasPermission>
                                            <shiro:hasPermission name="insole:isenable">
                                                <c:if test="${insole.valid == 1 && insole.status == 2}" >
                                                    <a href="javascript:onclick = changeStatus('${insole.id}',0);"><span
                                                            style="color: red;font-weight: bold;">禁用</span></a>
                                                </c:if>
                                                <c:if test="${insole.valid == 0 && insole.status != 1}">
                                                    <a href="javascript:onclick = changeStatus('${insole.id}',1);"><span
                                                            style="color: green;font-weight: bold;">启用</span></a>
                                                </c:if>
                                            </shiro:hasPermission>
                                        </div>
                                    </td>
                                </tr>
                            </c:forEach>
                            </tbody>
                        </table>
                        <jsp:include page="/WEB-INF/jsp/common/pageHelper.jsp"/>
                    </div>
                </div>
            </div>
        </div><!-- /.col -->
    </div><!-- /.row -->
</div><!-- /.page-content -->

<script type="text/javascript">
    window.jQuery || document.write("<script src='${baseurl}statics/assets/js/jquery-2.0.3.min.js'>" + "<" + "/script>");
</script>

<!-- <![endif]-->

<!--[if IE]>
<script type="text/javascript">
    window.jQuery || document.write("<script src='${baseurl}statics/assets/js/jquery-1.10.2.min.js'>" + "<" + "/script>");
</script>
<![endif]-->

<script type="text/javascript">
    if ("ontouchend" in document) document.write("<script src='${baseurl}statics/assets/js/jquery.mobile.custom.min.js'>" + "<" + "/script>");
</script>
<script src="${baseurl}statics/assets/js/bootstrap.min.js"></script>
<script src="${baseurl}statics/assets/js/typeahead-bs2.min.js"></script>


<script src="${baseurl}statics/assets/js/ace-elements.min.js"></script>
<script src="${baseurl}statics/assets/js/ace.min.js"></script>

<!-- inline scripts related to this page -->

<script type="text/javascript">

    jQuery(function ($) {
//        var oTable1 = $('#sample-table-2').dataTable({
//            "aoColumns": [
//                {"bSortable": false},
//                null, null, null, null, null,
//                {"bSortable": false}
//            ]
//        });

        $('#checkAll').click(function(){
            var r=confirm("确定要一键审核吗?")
            if (r==true){
                $("#checkAll").hide();
                $("#noCheckAll").show();
                $.ajax({
                    url: "${baseurl}insole/keyPass",
                    type: "post",
                    dataType:"json",
                    success: function (json) {
                        location.reload();
                    },
                    error: function (json) {
                        alert("error");
                    }
                });
            }
        });

        $("#noCheckAll").click(function () {
            var r=confirm("确定要取消一键审核吗?")
            if (r==true){
                $("#noCheckAll").hide();
                $("#checkAll").show();
                $.ajax({
                    url: "${baseurl}insole/noKeyPass",
                    type: "post",
                    dataType:"json",
                    success: function (json) {

                    },
                    error: function (json) {
                        alert("error");
                    }
                });
            }
        });


        $('table th input:checkbox').on('click', function () {
            var that = this;
            $(this).closest('table').find('tr > td:first-child input:checkbox')
                .each(function () {
                    this.checked = that.checked;
                    $(this).closest('tr').toggleClass('selected');
                });

        });


        $('[data-rel="tooltip"]').tooltip({placement: tooltip_placement});
        function tooltip_placement(context, source) {
            var $source = $(source);
            var $parent = $source.closest('table')
            var off1 = $parent.offset();
            var w1 = $parent.width();
            var off2 = $source.offset();
            var w2 = $source.width();
            if (parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2)) return 'right';
            return 'left';
        }
    })

    /*
     * 改变中底状态：禁用或启用
     */
     function changeStatus(id, status){
         var adminName = $("#adminName").val();
         var k;
         if(status=="0"){
             k = window.confirm("确定启用！");
         }
         if(status=="1") {
             k = window.confirm("确定禁用！");
         }
         if (k) {
             $.ajax({
                 url: "${baseurl}insole/changeStatus",
                 data: {"insoleId": id,"isenable":status,"adminName":adminName},
                 type: "post",
                 dataType:"json",
                 success: function (json) {
                     if (json.code == 0) {
                         alert(json.message);
                         location.reload();
                     } else {
                         alert(json.message);
                     }
                 },
                 error: function (json) {
                     alert("error");
                 }
             });
         }

     }

    /*
     * 该表中底审核状态：审核通过或审核不通过
     */
    function changeCheckStatus(id,status){
        var adminName = $("#adminName").val();
        var k = false;
        if(status=="2"){
            k = window.confirm("是否通过！");
        }
        if(status=="3") {
            k = window.confirm("是否不通过！");
        }
        if (k) {
            $.ajax({
                url: "${baseurl}insole/changeCheckStatus",
                data: {"insoleId": id,"examine":status,"adminName":adminName},
                type: "post",
                dataType:"json",
                success: function (json) {
                    if (json.code == 0) {
                        alert(json.message);
                        location.reload();
                    } else {
                        alert(json.message);
                    }
                },
                error: function (json) {
                    alert("error");
                }
            });
        }
    }

</script>
</body>
</html>

